import { onBeforeUnmount, ref } from "vue";

export function useTime() {//封装函数
    const num = ref(1);
    
    const timer = setInterval(() => {
        num.value++;
    }, 1000);

    onBeforeUnmount(() => {
        clearInterval(timer);
    });

    return num;
}